package com.itzz.spring_zhoneHeng.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itzz.spring_zhoneHeng.pojo.Book;
import com.itzz.spring_zhoneHeng.pojo.Chapters;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ChaptersDao extends BaseMapper<Chapters> {
    //查询所有的章节
    List<Chapters> queryAllChapters(String bookName);

    //查询所有的书籍
    @Select("select * from book")
    List<Book> queryAll();

    //根据bookid和chapid添加到b_chap中
    @Insert("insert into b_chap(bookid,chapid) values(#{bookId},#{chapId})")
    int addb_chap(@Param("bookId") Integer bookId,@Param("chapId") Integer chapId);

    //根据
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    @Insert("insert into chapters(id,book_name,chapter,state) values(#{id},#{bookName},#{chapter},#{state})")
    int addChapters(Chapters chapters);

}
